let {userModel}=require("../Model");

let userMock=require("../mock/userMock.js");


// async function addUsers(){
//     let data=await userModel.insertMany(userMock);
//     console.log(data);
// }
// addUsers();

async function getUsers(filter, page = 1, limit = 10, sort = "_id") {
    let data = await userModel
                    .find(filter)
                    .skip((page - 1) * limit)
                    .limit(limit)
                    .sort(sort);
    return data
}

async function getCount(){
    let data = await userModel.find().count()

    return data
}


module.exports.getUsers = getUsers;
module.exports.getCount = getCount;